<template>
  <div class="cart-container">
    <div class="title">
      <span class="all" v-show="show" @click="handleChange">{{changeTitle}}</span>
      <span class="all all2" v-show="!show">白色</span>
      <span class="cart">购物车</span>
      <span class="edit" @click="handleShow" v-show="!show">编辑</span> 
      <span class="edit" v-show="show" @click="deleteList">删除</span>
    </div>
    <!-- checked === true ? deleteList : '' -->
    <ul class="list">
      <li>
        <checkbox-group class="checkbox-wrapper">
          <div class="checkbox" v-show="show">
              <checkbox :checked="checked"/>
          </div>
        </checkbox-group>
        <div class="img"><img src="/static/images/img.jpg" alt=""></div>
        <div class="desc">
          <h5>BCD牌精选DD牌精选D牌精选D牌精选D牌精选D牌精选牌精选东北大米</h5>
          <p>￥250.00</p>
          <span>25kg装</span>
        </div>
        <div class="cart-control">
          <cart-control></cart-control>
        </div>
      </li>
       <li>
        <checkbox-group class="checkbox-wrapper">
          <div class="checkbox" v-show="show">
              <checkbox :checked="checked"/>
          </div>
        </checkbox-group>
        <div class="img"><img src="/static/images/img.jpg" alt=""></div>
        <div class="desc">
          <h5>BCD牌精选东北大米</h5>
          <p>￥250.00+70积分</p>
          <span>25kg装</span>
        </div>
        <div class="cart-control">
          <cart-control></cart-control>
        </div>
      </li>
    </ul>
    <div class="bottom">
      <shop-cart></shop-cart>
    </div>
  </div>
</template>

<script>
import cartControl from '../../components/cartcontrol'
import shopCart from '../../components/shopcart'
import {showModelSucc} from '../../utils/index.js'
export default {
  components: {
    cartControl,
    shopCart
  },
  data () {
    return {
      show: false,
      checked: false,
      changeTitle: '全选'
      // hide: false
    }
  },
  methods: {
    handleShow () {
      this.show = !this.show
    },
    handleChange () {
      if (this.changeTitle === '全选') {
        this.allSelected()
      } else {
        this.allCancel()
      }
    },
    allSelected () {
      this.checked = true
      this.changeTitle = '取消'
    },
    allCancel () {
      this.show = !this.show
      this.changeTitle = '全选'
      this.checked = false
    },
    // isDelete () {
    //   console.log(111)
    //   if (this.checked === true) {
    //     this.deleteList()
    //   }
    //   console.log(this.checked)
    // },
    deleteList () {
      showModelSucc('确定删除此条列表？')
      console.log(2222)
    }
  }
}
</script>

<style lang="scss" scoped>
@import 'static/css/base.scss';
.cart-container{
  background: #f9f9f9;
  .title{
    text-align: center;
    display: flex;
    justify-content: space-between;
    font-size: 30rpx;
    color: #333;
    height: 80rpx;
    line-height: 80rpx;
    background: #fff;
    padding:0 20rpx;
    .edit,.all{
      font-size: 28rpx;
    }
    .edit{
      color: #22ac38;
    }
    .all{
      color: #ed1c24;
    }
    .all2{
      color: #fff;
    }
  }
  .list{
    margin-top: 12rpx;
    color: #333;
    font-size: 26rpx;
    li{
      display: flex;
      justify-content: flex-start;
      background: #fff;
      padding: 10rpx 20rpx;
      margin-bottom: 4rpx;
      position: relative;
      .checkbox-wrapper{
        margin: 60rpx 10rpx 0 0;
        color: #22ac38;
        .checkbox{
          transform: scale(0.7)
        }
      }
      .img{
        width: 230rpx;
        height: 160rpx;
        overflow: hidden;
        flex: 0 0 230;
        img{
          width: 100%;
          height: 100%;
        }
      }
      .desc{
        margin-left: 30rpx;
        flex: 1;
        h5{
            width: 400rpx;
            @extend %text-limit
        }
        p{
          font-size: 28rpx;
          color: #ed1c24;
          margin: 30rpx 0;
        }
        span{
          color: #666;
        }
      }
      .cart-control{
        position: absolute;
        bottom: 10rpx;
        right: 20rpx;
      }
    }
  }
  .bottom{
    width: 100%;
    position: fixed;
    bottom: 0;
  }
}

</style>
